package com.imooc.order.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.imooc.order.dto.OrderDTO;
import com.imooc.order.message.StreamClient;

/**
 * 
 * @author jmlv
 * @date 2019年1月19日
 */
@RestController
public class SendMessageController {

	@Autowired
	private StreamClient streamClient;
	
	@GetMapping("/sendMessage")
	public void send() {
		String message = "now " + new Date();
		streamClient.output().send(MessageBuilder.withPayload(message).build());
	}
	
	@GetMapping("/sendOrder")
	public void sendOrder() {
		OrderDTO orderDTO = new OrderDTO();
		orderDTO.setOrderId("12345");
		streamClient.output().send(MessageBuilder.withPayload(orderDTO).build());
	}
}
